else
print_func = g_print;
- print_func ("usage: %s COMMAND [options]\n",
+ print_func ("usage: %s --repo=PATH COMMAND [options]\n",
argv[0]);
print_func ("Builtin commands:\n");
{
OstreeBuiltin *builtin;
const char *cmd;
+ const char *repo;
g_type_init ();
builtin = builtins;
- if (argc < 2)
+ if (argc < 3)
return usage (argv, 1);
- cmd = argv[1];
+ if (!g_str_has_prefix (argv[1], "--repo="))
+ return usage (argv, 1);
+ repo = argv[1] + strlen ("--repo=");
+
+ cmd = argv[2];
while (builtin->name)
{
int tmp_argc;
char **tmp_argv;
- tmp_argc = argc - 1;
+ tmp_argc = argc - 2;
tmp_argv = g_new0 (char *, tmp_argc + 1);
tmp_argv[0] = (char*)builtin->name;
for (i = 0; i < tmp_argc; i++)
- tmp_argv[i+1] = argv[i+2];
- if (!builtin->fn (tmp_argc, tmp_argv, NULL, &error))
+ tmp_argv[i+1] = argv[i+3];
+ if (!builtin->fn (tmp_argc, tmp_argv, repo, &error))
{
g_free (tmp_argv);
g_printerr ("%s\n", error->message);
#include <glib/gi18n.h>
-static char *repo_path;
-
static GOptionEntry options[] = {
- { "repo", 0, 0, G_OPTION_ARG_FILENAME, &repo_path, "Repository path", "repo" },
{ NULL }
};
gboolean
-ostree_builtin_checkout (int argc, char **argv, const char *prefix, GError **error)
+ostree_builtin_checkout (int argc, char **argv, const char *repo_path, GError **error)
{
GOptionContext *context;
gboolean ret = FALSE;
if (!g_option_context_parse (context, &argc, &argv, error))
goto out;
- if (repo_path == NULL)
- repo_path = ".";
-
repo = ostree_repo_new (repo_path);
if (!ostree_repo_check (repo, error))
goto out;
#include <glib/gi18n.h>
-static char *repo_path;
static gboolean separator_null;
static int from_fd = -1;
static gboolean from_stdin;
static char **removals;
static GOptionEntry options[] = {
- { "repo", 0, 0, G_OPTION_ARG_FILENAME, &repo_path, "Repository path", "repo" },
{ "subject", 's', 0, G_OPTION_ARG_STRING, &subject, "One line subject", "subject" },
{ "body", 'm', 0, G_OPTION_ARG_STRING, &body, "Full description", "body" },
{ "branch", 'b', 0, G_OPTION_ARG_STRING, &branch, "Branch", "branch" },
};
gboolean
-ostree_builtin_commit (int argc, char **argv, const char *prefix, GError **error)
+ostree_builtin_commit (int argc, char **argv, const char *repo_path, GError **error)
{
GOptionContext *context;
gboolean ret = FALSE;
OstreeRepo *repo = NULL;
+ char *cwd;
gboolean using_filename_cmdline;
gboolean using_filedescriptors;
GPtrArray *additions_array = NULL;
GChecksum *commit_checksum = NULL;
char **iter;
+ cwd = g_get_current_dir ();
+
context = g_option_context_new ("- Commit a new revision");
g_option_context_add_main_entries (context, options, NULL);
if (!g_option_context_parse (context, &argc, &argv, error))
goto out;
- if (repo_path == NULL)
- repo_path = ".";
- if (prefix == NULL)
- prefix = ".";
-
repo = ostree_repo_new (repo_path);
if (!ostree_repo_check (repo, error))
goto out;
g_ptr_array_add (removals_array, *iter);
if (!ostree_repo_commit (repo, branch, parent, subject, body, NULL,
- prefix, additions_array,
+ cwd, additions_array,
removals_array,
&commit_checksum,
error))
from_fd = temp_fd;
}
if (!ostree_repo_commit_from_filelist_fd (repo, branch, parent, subject, body, NULL,
- prefix, from_fd, separator,
+ cwd, from_fd, separator,
&commit_checksum, error))
{
if (temp_fd >= 0)
ret = TRUE;
g_print ("%s\n", g_checksum_get_string (commit_checksum));
out:
+ g_free (cwd);
if (context)
g_option_context_free (context);
g_clear_object (&repo);
#include <glib/gi18n.h>
-static char *repo_path;
-
#define FAST_QUERYINFO "standard::name,standard::type,standard::is-symlink,standard::symlink-target,unix::*"
static GOptionEntry options[] = {
- { "repo", 0, 0, G_OPTION_ARG_FILENAME, &repo_path, "Repository path", "repo" },
{ NULL }
};
}
gboolean
-ostree_builtin_compose (int argc, char **argv, const char *prefix, GError **error)
+ostree_builtin_compose (int argc, char **argv, const char *repo_path, GError **error)
{
GOptionContext *context;
gboolean ret = FALSE;
if (!g_option_context_parse (context, &argc, &argv, error))
goto out;
- if (repo_path == NULL)
- repo_path = ".";
-
repo = ostree_repo_new (repo_path);
if (!ostree_repo_check (repo, error))
goto out;
#include <glib/gi18n.h>
-static char *repo_path;
static gboolean quiet;
static GOptionEntry options[] = {
- { "repo", 0, 0, G_OPTION_ARG_FILENAME, &repo_path, "Repository path", NULL },
{ "quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet, "Don't display informational messages", NULL },
{ NULL }
};
}
gboolean
-ostree_builtin_fsck (int argc, char **argv, const char *prefix, GError **error)
+ostree_builtin_fsck (int argc, char **argv, const char *repo_path, GError **error)
{
GOptionContext *context;
HtFsckData data;
if (!g_option_context_parse (context, &argc, &argv, error))
goto out;
- if (repo_path == NULL)
- repo_path = ".";
-
data.n_objects = 0;
repo = ostree_repo_new (repo_path);
#include <glib/gi18n.h>
-static char *repo_path;
static gboolean archive;
static GOptionEntry options[] = {
- { "repo", 0, 0, G_OPTION_ARG_FILENAME, &repo_path, "Repository path", NULL },
{ "archive", 0, 0, G_OPTION_ARG_NONE, &archive, "Initialize repository as archive", NULL },
{ NULL }
};
gboolean
-ostree_builtin_init (int argc, char **argv, const char *prefix, GError **error)
+ostree_builtin_init (int argc, char **argv, const char *repo_path, GError **error)
{
GOptionContext *context = NULL;
gboolean ret = FALSE;
if (!g_option_context_parse (context, &argc, &argv, error))
goto out;
- if (repo_path == NULL)
- repo_path = ".";
-
repodir = ot_util_new_file_for_path (repo_path);
child = g_file_get_child (repodir, "config");
#include <glib/gi18n.h>
-static char *repo_path;
static gboolean ignore_exists;
static gboolean force;
static GOptionEntry options[] = {
- { "repo", 0, 0, G_OPTION_ARG_FILENAME, &repo_path, "Repository path", "repo" },
{ "ignore-exists", 'n', 0, G_OPTION_ARG_NONE, &ignore_exists, "Don't error if file exists", NULL },
{ "force", 'f', 0, G_OPTION_ARG_NONE, &force, "If object exists, relink file", NULL },
{ NULL }
};
gboolean
-ostree_builtin_link_file (int argc, char **argv, const char *prefix, GError **error)
+ostree_builtin_link_file (int argc, char **argv, const char *repo_path, GError **error)
{
GOptionContext *context;
gboolean ret = FALSE;
if (!g_option_context_parse (context, &argc, &argv, error))
goto out;
- if (repo_path == NULL)
- repo_path = ".";
-
repo = ostree_repo_new (repo_path);
if (!ostree_repo_check (repo, error))
goto out;
#include <glib/gi18n.h>
-static char *repo_path;
-
static GOptionEntry options[] = {
- { "repo", 0, 0, G_OPTION_ARG_FILENAME, &repo_path, "Repository path", "repo" },
{ NULL }
};
gboolean
-ostree_builtin_log (int argc, char **argv, const char *prefix, GError **error)
+ostree_builtin_log (int argc, char **argv, const char *repo_path, GError **error)
{
GOptionContext *context;
gboolean ret = FALSE;
if (!g_option_context_parse (context, &argc, &argv, error))
goto out;
- if (repo_path == NULL)
- repo_path = ".";
- if (prefix == NULL)
- prefix = ".";
-
if (argc < 2)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
#include <libsoup/soup-gnome.h>
-static char *repo_path;
-
static GOptionEntry options[] = {
- { "repo", 0, 0, G_OPTION_ARG_FILENAME, &repo_path, "Repository path", "repo" },
{ NULL }
};
}
gboolean
-ostree_builtin_pull (int argc, char **argv, const char *prefix, GError **error)
+ostree_builtin_pull (int argc, char **argv, const char *repo_path, GError **error)
{
GOptionContext *context;
gboolean ret = FALSE;
if (!g_option_context_parse (context, &argc, &argv, error))
goto out;
- if (repo_path == NULL)
- repo_path = ".";
-
repo = ostree_repo_new (repo_path);
if (!ostree_repo_check (repo, error))
goto out;
#include <glib/gi18n.h>
-static char *repo_path;
-
static GOptionEntry options[] = {
- { "repo", 0, 0, G_OPTION_ARG_FILENAME, &repo_path, "Repository path", "repo" },
{ NULL }
};
}
gboolean
-ostree_builtin_remote (int argc, char **argv, const char *prefix, GError **error)
+ostree_builtin_remote (int argc, char **argv, const char *repo_path, GError **error)
{
GOptionContext *context;
gboolean ret = FALSE;
if (!g_option_context_parse (context, &argc, &argv, error))
goto out;
- if (repo_path == NULL)
- repo_path = ".";
-
repo = ostree_repo_new (repo_path);
if (!ostree_repo_check (repo, error))
goto out;
static char *repo_path;
static GOptionEntry options[] = {
- { "repo", 0, 0, G_OPTION_ARG_FILENAME, &repo_path, "Repository path", "repo" },
{ NULL }
};
gboolean
-ostree_builtin_rev_parse (int argc, char **argv, const char *prefix, GError **error)
+ostree_builtin_rev_parse (int argc, char **argv, const char *repo_path, GError **error)
{
GOptionContext *context;
gboolean ret = FALSE;
if (!g_option_context_parse (context, &argc, &argv, error))
goto out;
- if (repo_path == NULL)
- repo_path = ".";
-
repo = ostree_repo_new (repo_path);
if (!ostree_repo_check (repo, error))
goto out;
#include <glib/gi18n.h>
-static char *repo_path;
static gboolean quiet;
static GOptionEntry options[] = {
- { "repo", 0, 0, G_OPTION_ARG_FILENAME, &repo_path, "Repository path", "repo" },
{ "quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet, "Don't display informational messages", NULL },
{ NULL }
};
gboolean
-ostree_builtin_run_triggers (int argc, char **argv, const char *prefix, GError **error)
+ostree_builtin_run_triggers (int argc, char **argv, const char *repo_path, GError **error)
{
GOptionContext *context;
gboolean ret = FALSE;
if (!g_option_context_parse (context, &argc, &argv, error))
goto out;
- if (repo_path == NULL)
- repo_path = ".";
-
repo = ostree_repo_new (repo_path);
if (!ostree_repo_check (repo, error))
goto out;
#include <glib/gi18n.h>
-static char *repo_path;
-
static GOptionEntry options[] = {
- { "repo", 0, 0, G_OPTION_ARG_FILENAME, &repo_path, "Repository path", "repo" },
{ NULL }
};
gboolean
-ostree_builtin_show (int argc, char **argv, const char *prefix, GError **error)
+ostree_builtin_show (int argc, char **argv, const char *repo_path, GError **error)
{
GOptionContext *context;
gboolean ret = FALSE;
if (!g_option_context_parse (context, &argc, &argv, error))
goto out;
- if (repo_path == NULL)
- repo_path = ".";
-
repo = ostree_repo_new (repo_path);
if (!ostree_repo_check (repo, error))
goto out;
typedef struct {
const char *name;
- gboolean (*fn) (int argc, char **argv, const char *prefix, GError **error);
+ gboolean (*fn) (int argc, char **argv, const char *repo, GError **error);
int flags; /* OstreeBuiltinFlags */
} OstreeBuiltin;
-gboolean ostree_builtin_checkout (int argc, char **argv, const char *prefix, GError **error);
-gboolean ostree_builtin_commit (int argc, char **argv, const char *prefix, GError **error);
-gboolean ostree_builtin_compose (int argc, char **argv, const char *prefix, GError **error);
-gboolean ostree_builtin_init (int argc, char **argv, const char *prefix, GError **error);
-gboolean ostree_builtin_log (int argc, char **argv, const char *prefix, GError **error);
-gboolean ostree_builtin_link_file (int argc, char **argv, const char *prefix, GError **error);
-gboolean ostree_builtin_pull (int argc, char **argv, const char *prefix, GError **error);
-gboolean ostree_builtin_run_triggers (int argc, char **argv, const char *prefix, GError **error);
-gboolean ostree_builtin_fsck (int argc, char **argv, const char *prefix, GError **error);
-gboolean ostree_builtin_show (int argc, char **argv, const char *prefix, GError **error);
-gboolean ostree_builtin_rev_parse (int argc, char **argv, const char *prefix, GError **error);
-gboolean ostree_builtin_remote (int argc, char **argv, const char *prefix, GError **error);
+gboolean ostree_builtin_checkout (int argc, char **argv, const char *repo, GError **error);
+gboolean ostree_builtin_commit (int argc, char **argv, const char *repo, GError **error);
+gboolean ostree_builtin_compose (int argc, char **argv, const char *repo, GError **error);
+gboolean ostree_builtin_init (int argc, char **argv, const char *repo, GError **error);
+gboolean ostree_builtin_log (int argc, char **argv, const char *repo, GError **error);
+gboolean ostree_builtin_link_file (int argc, char **argv, const char *repo, GError **error);
+gboolean ostree_builtin_pull (int argc, char **argv, const char *repo, GError **error);
+gboolean ostree_builtin_run_triggers (int argc, char **argv, const char *repo, GError **error);
+gboolean ostree_builtin_fsck (int argc, char **argv, const char *repo, GError **error);
+gboolean ostree_builtin_show (int argc, char **argv, const char *repo, GError **error);
+gboolean ostree_builtin_rev_parse (int argc, char **argv, const char *repo, GError **error);
+gboolean ostree_builtin_remote (int argc, char **argv, const char *repo, GError **error);
G_END_DECLS
mkdir repo
cd repo
ot_repo="--repo=`pwd`"
+ export OSTREE="ostree ${ot_repo}"
cd ../files
- export ot_repo
if test "$mode" = "archive"; then
- ostree init --archive $ot_repo
+ $OSTREE init --archive
else
- ostree init $ot_repo
+ $OSTREE init
fi
- ostree commit $ot_repo -b test2 -s "Test Commit 1" -m "Commit body first" --add=firstfile --add=somelink
- ostree commit $ot_repo -b test2 -s "Test Commit 2" -m "Commit body second" --add=baz/cow --add=baz/saucer --add=baz/deeper/ohyeah --add=baz/another/y --add=baz/alink
- ostree fsck -q $ot_repo
+ $OSTREE commit -b test2 -s "Test Commit 1" -m "Commit body first" --add=firstfile --add=somelink
+ $OSTREE commit -b test2 -s "Test Commit 2" -m "Commit body second" --add=baz/cow --add=baz/saucer --add=baz/deeper/ohyeah --add=baz/another/y --add=baz/alink
+ $OSTREE fsck -q
cd $oldpwd
}
mkdir ostree-srv
cd ostree-srv
mkdir gnomerepo
- ostree init --archive --repo=gnomerepo
+ ostree --repo=gnomerepo init --archive
mkdir gnomerepo-files
cd gnomerepo-files
echo first > firstfile
mkdir baz
echo moo > baz/cow
echo alien > baz/saucer
- find | grep -v '^\.$' | ostree commit --repo=${test_tmpdir}/ostree-srv/gnomerepo -b main -s "A remote commit" -m "Some Commit body" --from-stdin
+ find | grep -v '^\.$' | ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo commit -b main -s "A remote commit" -m "Some Commit body" --from-stdin
mkdir baz/deeper
- ostree commit --repo=${test_tmpdir}/ostree-srv/gnomerepo -b main -s "Add deeper" --add=baz/deeper
+ ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo commit -b main -s "Add deeper" --add=baz/deeper
echo hi > baz/deeper/ohyeah
mkdir baz/another/
echo x > baz/another/y
- find | grep -v '^\.$' | ostree commit --repo=${test_tmpdir}/ostree-srv/gnomerepo -b main -s "The rest" --from-stdin
+ find | grep -v '^\.$' | ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo commit -b main -s "The rest" --from-stdin
cd ..
rm -rf gnomerepo-files
exit 1
fi
cd ${oldpwd}
+
+ export OSTREE="ostree --repo=repo"
}
trap 'die' EXIT
echo "ok check"
-ostree checkout $ot_repo test2 checkout-test2
+$OSTREE checkout test2 checkout-test2
echo "ok checkout"
-ostree rev-parse $ot_repo test2
-ostree rev-parse $ot_repo 'test2^'
-ostree rev-parse $ot_repo 'test2^^' 2>/dev/null && (echo 1>&2 "rev-parse test2^^ unexpectedly succeeded!"; exit 1)
+$OSTREE rev-parse test2
+$OSTREE rev-parse 'test2^'
+$OSTREE rev-parse 'test2^^' 2>/dev/null && (echo 1>&2 "rev-parse test2^^ unexpectedly succeeded!"; exit 1)
echo "ok rev-parse"
cd checkout-test2
assert_has_file baz/deeper/ohyeah
echo "ok content"
-ostree commit $ot_repo -b test2 -s delete -r firstfile
+$OSTREE commit -b test2 -s delete -r firstfile
assert_has_file firstfile # It should still exist in this checkout
cd $test_tmpdir
-ostree checkout $ot_repo test2 $test_tmpdir/checkout-test2-2
+$OSTREE checkout test2 $test_tmpdir/checkout-test2-2
cd $test_tmpdir/checkout-test2-2
assert_not_has_file firstfile
assert_has_file baz/saucer
echo anotherone > another/nested/tree/1
echo whee2 > another/whee
# FIXME - remove grep for .
-find | grep -v '^\.$' | ostree commit $ot_repo -b test2 -s "From find" --from-stdin
+find | grep -v '^\.$' | $OSTREE commit -b test2 -s "From find" --from-stdin
echo "ok stdin commit"
cd ${test_tmpdir}
-ostree checkout $ot_repo test2 $test_tmpdir/checkout-test2-3
+$OSTREE checkout test2 $test_tmpdir/checkout-test2-3
cd checkout-test2-3
assert_has_file a/nested/2
assert_file_has_content a/nested/2 'two2'
setup_test_repository "archive"
echo "ok setup"
-ostree checkout $ot_repo test2 checkout-test2
+$OSTREE checkout test2 checkout-test2
echo "ok checkout"
cd checkout-test2
echo "1..1"
setup_test_repository "regular"
-ostree log $ot_repo test2 > $test_tmpdir/log.txt
+$OSTREE log test2 > $test_tmpdir/log.txt
assert_file_has_content $test_tmpdir/log.txt "Test Commit 1"
assert_file_has_content $test_tmpdir/log.txt "Test Commit 2"
echo "ok log"
echo '1..2'
setup_test_repository "regular"
-ostree remote add $ot_repo origin http://example.com/ostree/gnome
+$OSTREE remote add origin http://example.com/ostree/gnome
echo "ok remote add"
assert_file_has_content $test_tmpdir/repo/config "example.com"
echo "ok config"
setup_fake_remote_repo1
cd ${test_tmpdir}
mkdir repo
-ostree init --repo=repo
-ostree remote --repo=repo add origin $(cat httpd-address)/ostree/gnomerepo
-ostree pull --repo=repo origin main
+$OSTREE init
+$OSTREE remote add origin $(cat httpd-address)/ostree/gnomerepo
+$OSTREE pull origin main
echo "ok pull"
setup_test_repository "regular"
-ostree checkout $ot_repo test2 checkout-test2
+$OSTREE checkout test2 checkout-test2
cd "${test_tmpdir}"
mkdir artifact-libfoo-runtime
mkdir -p usr/share
echo 'some data' > usr/share/foo.data
-find | grep -v '^\.$' | ostree commit $ot_repo -b artifact-libfoo-runtime -s 'Build 12345 of libfoo' --from-stdin
+find | grep -v '^\.$' | $OSTREE commit -b artifact-libfoo-runtime -s 'Build 12345 of libfoo' --from-stdin
cd "${test_tmpdir}"
mkdir artifact-libfoo-devel
mkdir -p usr/share/doc
echo 'some documentation' > usr/share/doc/foo.txt
-find | grep -v '^\.$' | ostree commit $ot_repo -b artifact-libfoo-devel -s 'Build 12345 of libfoo' --from-stdin
+find | grep -v '^\.$' | $OSTREE commit -b artifact-libfoo-devel -s 'Build 12345 of libfoo' --from-stdin
cd "${test_tmpdir}"
mkdir artifact-barapp
mkdir -p usr/bin
echo 'another ELF file' > usr/bin/bar
-find | grep -v '^\.$' | ostree commit $ot_repo -b artifact-barapp -s 'Build 42 of barapp' --from-stdin
+find | grep -v '^\.$' | $OSTREE commit -b artifact-barapp -s 'Build 42 of barapp' --from-stdin
echo 'ok artifacts committed'
cd "${test_tmpdir}"
-ostree compose $ot_repo some-compose artifact-libfoo-runtime artifact-libfoo-devel artifact-barapp
+$OSTREE compose some-compose artifact-libfoo-runtime artifact-libfoo-devel artifact-barapp
echo 'ok compose command'
cd some-compose